package com.dongwu.manager.web;

import com.dongwu.common.dto.Result;
import com.dongwu.common.utils.Exceptions;
import com.dongwu.config.TransfersConfig;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;

@Controller
@RequestMapping("/manager/transfers")
public class TransfersController {


    /**
     *
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/trans")
    @ResponseBody
    public Result addRecord(@RequestParam(value = "openid")String openid,
                            @RequestParam(value = "amount") Integer amount) throws ParseException {
        try {
            TransfersConfig transfersConfig = new TransfersConfig();
            String result = transfersConfig.transfers(openid,amount);
            return Result.successResult(result);
        } catch (Exception e) {
            String msg = Exceptions.getMessage(e);
            return Result.errorResult(msg);
        }

    }


}
